package com.LeeCode;

/**
 * 对称二叉树
 */

public class Code101 {
    public static void main(String[] args) {

    }

    public boolean isSymmetric(TreeNode root) {
        return check(root.left, root.right);
    }

    public boolean check(TreeNode p, TreeNode q) {
        if (p == null || q == null) return p == q;

        if (p.val != q.val) return false;

        return check(p.left, q.right) && check(p.right, q.left);
    }
}
